
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "tipo_presentacion_mercaderia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoPresentacionMercaderia.findAll", query = "SELECT t FROM TipoPresentacionMercaderia t"),
    @NamedQuery(name = "TipoPresentacionMercaderia.findByCodTipPreMer", query = "SELECT t FROM TipoPresentacionMercaderia t WHERE t.codTipPreMer = :codTipPreMer"),
    @NamedQuery(name = "TipoPresentacionMercaderia.findByDesTipPreMer", query = "SELECT t FROM TipoPresentacionMercaderia t WHERE t.desTipPreMer = :desTipPreMer")})
public class TipoPresentacionMercaderia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_tip_pre_mer")
    private Short codTipPreMer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "des_tip_pre_mer")
    private String desTipPreMer;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codTipPreMer")
    private Collection<Mercaderia> mercaderiaCollection;

    public TipoPresentacionMercaderia() {
    }

    public TipoPresentacionMercaderia(Short codTipPreMer) {
        this.codTipPreMer = codTipPreMer;
    }

    public TipoPresentacionMercaderia(Short codTipPreMer, String desTipPreMer) {
        this.codTipPreMer = codTipPreMer;
        this.desTipPreMer = desTipPreMer;
    }

    public Short getCodTipPreMer() {
        return codTipPreMer;
    }

    public void setCodTipPreMer(Short codTipPreMer) {
        this.codTipPreMer = codTipPreMer;
    }

    public String getDesTipPreMer() {
        return desTipPreMer;
    }

    public void setDesTipPreMer(String desTipPreMer) {
        this.desTipPreMer = desTipPreMer;
    }

    @XmlTransient
    public Collection<Mercaderia> getMercaderiaCollection() {
        return mercaderiaCollection;
    }

    public void setMercaderiaCollection(Collection<Mercaderia> mercaderiaCollection) {
        this.mercaderiaCollection = mercaderiaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipPreMer != null ? codTipPreMer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof TipoPresentacionMercaderia)) {
            return false;
        }
        TipoPresentacionMercaderia other = (TipoPresentacionMercaderia) object;
        if ((this.codTipPreMer == null && other.codTipPreMer != null) || (this.codTipPreMer != null && !this.codTipPreMer.equals(other.codTipPreMer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.raphapy.autoventas.model.TipoPresentacionMercaderia[ codTipPreMer=" + codTipPreMer + " ]";
    }
    
}
